<?php

namespace Biz\model\redPacket;

use Doraemon\pockets\datebase\BaseDbModel;

class RedPacketsConfig extends BaseDbModel
{

    const _CONFIG_FILE_ = 'db_shop';

    const _CONFIG_SELECT_ = 'db_redpacket';

    const _DATABASE_ = 'biz_red_packet';

    const _TABLE_NAME = 'red_packets_config';

    const STATUS_NORMAL = 1;//默认
    const STATUS_CLOSE = 0;//已关闭
    const STATUS_DEL = 9;//已删除


    /**
     * 获取当前正在进行中的红包
     * @return array
     */
    public static function getPacketConfigInfo()
    {
        $now = date('Y-m-d H:i:s');
        $list = self::select('*', ['start_time[<]' => $now, 'end_time[>]' => $now, 'status' => self::STATUS_NORMAL]);
        $info = [];
        if ($list) {
            $info = $list[0];
            foreach ($list as $row) {
                if ($row['big_sales']) {//大促
                    $info = $row;
                    break;
                }
            }
        }
        return $info;
    }

}